﻿using System;
using System.Collections.Generic;
using System.Text;
using DAL.DateSet.ColorTableAdapters;
using DAL;
using DAL.DateSet;
namespace BLL.Wrapper
{
    public class ColorWrapper : ColorTableAdapter
    {
        public Color.ColorDataTable getall()
        {
            return GetData();
        }

        public void addARecord(Color.ColorRow row)
        {
            Insert(row.goodsID, row.colorName, row.colorNum, row.colorCreator,row.colorCreateDate);
        }

        public void deleteByID(int id)
        {
            string sql = "delete from Color where colorID = " + id.ToString();
            HouseDiyHelper helper = HouseDiyHelper.GetInstance();
            helper.initOle();
            helper.delete(sql);
        }

        public void updateARecord(Color.ColorRow row)
        {
            Color.ColorDataTable table = GetData();
            for (int i = 0; i < table.Rows.Count; i++)
            {
                if (Convert.ToInt32(table.Rows[i]["colorID"]) == row.colorID)
                {
                    table.Rows[i]["goodsID"] = row.goodsID;
                    table.Rows[i]["colorName"] = row.colorName;
                    table.Rows[i]["colorNum"] = row.colorNum;
                    table.Rows[i]["colorCreator"] = row.colorCreator;
                    table.Rows[i]["colorCreateDate"] = row.colorCreateDate;
                    break;
                }
            }
            Update(table);
        }
    }
}
